package Long.Lu.Dao;


import Long.Lu.pojo.Deploy;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @description:
 * @author: ty
 * @createDate: 2020/10/26
 * @version: 1.0
 */
@Repository
public interface DeployDao extends JpaRepository<Deploy, Integer> {

    @Transactional  //提交事务  执行增删改需要的
    @Modifying(clearAutomatically = true)  //表示执行增删改CRU操作的时候，清楚实体类的数据
    @Query(value = "delete from deploy where deploy_id=:deployId",nativeQuery = true)
    void deleteDeployByDeployId(@Param("deployId") Integer deployId);

    //批量删除用户
    @javax.transaction.Transactional
    @Modifying(clearAutomatically = true)
    //@Query 定义sql的注解。nativeQuery = true 表示定义是sql语句，false 是定HQL语句
    @Query(value="delete  from deploy  where deploy_id in(:deployIds)",nativeQuery = true)
    void deleteAllDeployByIds(@Param("deployIds") List<String> deployIds);
}
